// import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:get/get.dart';
import 'package:yinshui_caiying/utils/colors.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yinshui_caiying/widgets/border_dashed.dart';

///开关选择器
///[title]左侧标题,*必填
///
///[groupValue]值
///
///[dataList]展示列表
///
///[hasBorder]是否展示下划线，默认true
class FormRadio extends StatelessWidget {
  String title;
  Rx<String> groupValue;
  List dataList;
  bool hasBorder;
  FormRadio(
      {required this.title,
      required this.groupValue,
      required this.dataList,
      this.hasBorder = true});

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Container(
          width: 1.sw,
          height: 147.h,
          child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                Text(title,
                    style: TextStyle(
                      fontSize: 40.sp,
                      fontWeight: FontWeight.w400,
                    )),
                // Expanded(child: RadioGroup()),
                Expanded(
                    child: Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    SizedBox(
                      width: 150.w,
                    ),
                    Expanded(
                      child: Obx(() => RadioListTile(
                          value: '0',
                          activeColor: MyColors.main,
                          title: Container(
                            child: Text('否',
                                style: TextStyle(
                                  color: Color.fromRGBO(193, 192, 192, 1),
                                  fontSize: 40.sp,
                                  fontWeight: FontWeight.w400,
                                )),
                          ),
                          groupValue: groupValue.value,
                          onChanged: (value) {
                            groupValue.value = value.toString();
                          })),
                    ),
                    Expanded(
                      child: Obx(() => RadioListTile(
                          value: '1',
                          activeColor: MyColors.main,
                          title: Text('是',
                              style: TextStyle(
                                color: Color.fromRGBO(193, 192, 192, 1),
                                fontSize: 40.sp,
                                fontWeight: FontWeight.w400,
                              )),
                          groupValue: groupValue.value,
                          onChanged: (value) {
                            groupValue.value = value.toString();
                          })),
                    ),
                  ],
                ))
              ])),
      hasBorder ? MySeparator() : Container()
    ]);
  }

  // Widget RadioGroup() {
  //   List<Widget> list = [];
  //   // int flex = dataList.length == 0 ? 1 : dataList.length - 1;
  //   dataList.forEach((element) {
  //     list.add(Expanded(
  //       // flex: flex,
  //       child: Obx(() => RadioListTile(
  //           value: element.value.value.toString(),
  //           activeColor: MyColors.main,
  //           title: Text(element.value.name.toString(),
  //               style: TextStyle(
  //                 color: Color.fromRGBO(193, 192, 192, 1),
  //                 fontSize: 40.sp,
  //                 fontWeight: FontWeight.w400,
  //               )),
  //           groupValue: groupValue.value,
  //           onChanged: (value) {
  //             groupValue.value = value.toString();
  //           })),
  //     ));
  //   });
  //   return Row(
  //     mainAxisAlignment: MainAxisAlignment.spaceBetween,
  //     crossAxisAlignment: CrossAxisAlignment.center,
  //     children: list,
  //   );
  // }
}
